package org.itstack.demo.design.cuisine;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

/**
 * @Author: fanYuLe
 * @CreateTime: 2023-12-12  15:36
 * @Description:
 */
public class EGM {
    private final Logger logger = LoggerFactory.getLogger(EGM.class);

    private final Map<String,String> dataMap = new ConcurrentHashMap<>();

    public String gain(String key){
        logger.info("EGM获取数据 key：{}",key);
        return dataMap.get(key);
    }

    public void set(String key,String value){
        logger.info("EGM写入数据 key：{} val：{}",key,value);
        dataMap.put(key, value);
    }

    public void setEx(String key, String vale, long timeout, TimeUnit timeUnit){
        logger.info("EGM写入数据 key：{} val：{} timeout：{} timeUnit：{}",key,vale,timeout,timeUnit.toString());
        dataMap.put(key,vale);
    }

    public void delete(String key){
        logger.info("EGM删除数据 key：{}",key);
        dataMap.remove(key);
    }
}
